package io.a.hello;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import static io.a.hello.Const.QUEUE_NAME;

public class Publisher {


    public static void main(String[] args) throws Exception {
        //1. 获取连接对象
        Connection connection = RabbitmqConnectionUtil.getConnection();

        //2. 构建Channel
        Channel channel = connection.createChannel();

        //3. 构建队列
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);

        //4. 发布消息
        String message = "Hello World!";
        channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
        System.out.println("消息发送成功！");
    }


}
